﻿@using Abp.Authorization.Users
@using DevM.Web.Startup
@model DevM.Web.Models.Projects.EnvironmentListViewModel
@{
    ViewBag.CurrentPageName = PageNames.Environments; // The menu item will be active for this page.
}
@section scripts
{
    <script src="~/js/boostrap-pagination.js"></script>
    <script src="~/view-resources/Views/Projects/Environment.js" asp-append-version="true"></script>
}
<ol class="breadcrumb">
    <li><a href="@Url.Action("Index","Projects")">@L("Projects")</a></li>
    <li class="active">@L("Environments")</li>
</ol>
<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card">
            <div class="header">
                <h2>
                    @L("Environments") : @Model.Project.Name 
                </h2>
                <ul class="header-dropdown m-r--5">
                    <li class="dropdown">
                        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            <i class="material-icons">more_vert</i>
                        </a>
                        <ul class="dropdown-menu pull-right">
                            <li><a id="RefreshButton" href="javascript:void(0);" class="waves-effect waves-block"><i class="material-icons">refresh</i>@L("Refresh")</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="body table-responsive">
                <table class="table">
                    <thead>
                        <tr>
                            <th>@L("Name")</th>
                            <th>@L("Host")</th>
                            <th>@L("Color")</th>
                            @*<th>@L("Order")</th>*@
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var environment in Model.Environments)
                        {
                        <tr>
                            <td>@environment.Name</td>
                            <td>@environment.Host</td>
                            <td style="color:@environment.Color">@environment.Color</td>
                            @*<td>@environment.Order</td>*@
                            <td class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                                    <i class="material-icons">menu</i>
                                </a>
                                <ul class="dropdown-menu pull-right">
                                    <li><a href="#" class="waves-effect waves-block edit-environment" data-environment-id="@environment.Id" data-toggle="modal" data-target="#EnvironmentEditModal"><i class="material-icons">edit</i>@L("Edit")</a></li>
                                    <li><a href="#" class="waves-effect waves-block delete-environment" data-environment-id="@environment.Id" data-environment-name="@environment.Name"><i class="material-icons">delete_sweep</i>@L("Delete")</a></li>
                                </ul>
                            </td>
                        </tr>
                        }
                    </tbody>
                </table>
                <button type="button" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-right" data-toggle="modal" data-target="#EnvironmentCreateModal">
                    <i class="material-icons">add</i>
                </button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="EnvironmentCreateModal" tabindex="-1" role="dialog" aria-labelledby="UserCreateModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">
                    <span>@L("CreateNewEnvironment")</span>
                </h4>
            </div>
            <div class="modal-body">
                <form name="projectCreateForm" role="form" novalidate class="form-validation">
                    <ul class="nav nav-tabs tab-nav-right" role="tablist">
                        <li role="presentation" class="active"><a href="#create-environment-details" data-toggle="tab">@L("EnvironmentDetails")</a></li>

                    </ul>
                    <div class="tab-content">
                        <div role="tabpanel" class="tab-pane animated fadeIn active" id="create-environment-details">
                            <div class="row clearfix" style="margin-top:10px;">
                                <div class="col-sm-12">
                                    <div class="form-group form-float">
                                        <div class="form-line">
                                            <input class="form-control" type="text" name="Name" required maxlength="200" minlength="2">
                                            <label class="form-label">@L("Name")</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row clearfix" style="margin-top:10px;">
                                <div class="col-sm-12">
                                    <div class="form-group form-float">
                                        <div class="form-line">
                                            <input class="form-control" type="text" name="Host"  maxlength="200" minlength="2">
                                            <label class="form-label">@L("Host")</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row clearfix">
                                <div class="col-sm-12">
                                    <div class="form-group form-float">
                                        <div class="form-line">
                                            <textarea type="text" name="DbConnectStr" class="form-control" maxlength="2000"></textarea>
                                            <label class="form-label">@L("DbConnectStr")</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row clearfix">
                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <div class="form-line">
                                            <input id="name" type="text" name="DbType" maxlength="32" class="validate form-control">
                                            <label for="name" class="form-label">@L("DbType")</label>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <div class="form-line">
                                            <input id="surname" type="text" name="Color" required maxlength="32" class="validate form-control">
                                            <label for="surname" class="form-label">@L("Color")</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row clearfix">
                                <div class="col-sm-12">
                                    <div class="form-group form-float">
                                        <div class="form-line">
                                            <input type="text" name="Order" class="form-control" required maxlength="2000" />
                                            <label class="form-label">@L("Order")</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <input type="hidden" name="projectId" value="@ViewBag.ProjectId" />
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button>
                        <button type="submit" class="btn btn-primary waves-effect">@L("Save")</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="EnvironmentEditModal" tabindex="-1" role="dialog" aria-labelledby="UserEditModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">

        </div>
    </div>
</div>
